﻿using B.S.Shop.Application.Command;
using B.S.Shop.Domain;
using B.S.Shop.ErrorCode;
using B.S.Shop.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Shop.Application.Commandhandler
{
    public class ShopNameQueryCommandHandler : IRequestHandler<ShopNameQueryCommand, APIResult<List<ShopNameClass>>>
    {
        public ShopNameQueryCommandHandler(IBaseRepository<ShopNameClass> nameRepository)
        {
            NameRepository = nameRepository;
        }

        public IBaseRepository<ShopNameClass> NameRepository { get; }

        public async Task<APIResult<List<ShopNameClass>>> Handle(ShopNameQueryCommand request, CancellationToken cancellationToken)
        {
            var path = NameRepository.GetAll().ToList();
            return new APIResult<List<ShopNameClass>>
            {
                Code = ResultCode.success,
                Mag = "",
                data = path
            };
        }
    }
}
